package interfaceunderstand;

interface IShape {
    void draw();
}

//alt+enter：把放到红色的部分，alt+enter给你错误提示，会有提示选择。
class Rect implements IShape {

    @Override
    public void draw() {
        System.out.println("矩形！");
    }
}
class Flower implements IShape {
    @Override
    public void draw() {
        System.out.println("花！");
    }
}
class Cycle implements IShape {
    @Override
    public void draw() {
        System.out.println("圆！");
    }
}

public class Test2 {
    public static void drawMap(IShape iShape) {
        iShape.draw();
    }

    public static void main(String[] args) {
        Rect rect = new Rect();

        drawMap(rect);
        drawMap(new Cycle());
        drawMap(new Flower());
        //就下面代码来说，接口不能new自己，但是可以new实现我接口的类。
        //可以把接口想成特殊的类
        IShape iShape = new Cycle();
        //IShape iShape1 = new IShape();

    }
}